/*
 * Copyright (c) 2023, Texas Instruments Incorporated - http://www.ti.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 *
 * *  Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 *
 * *  Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * *  Neither the name of Texas Instruments Incorporated nor the names of
 *    its contributors may be used to endorse or promote products derived
 *    from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

/*
 *  ============ ti_msp_dl_config.h =============
 *  Configured MSPM0 DriverLib module declarations
 *
 *  DO NOT EDIT - This file is generated for the MSPM0G350X
 *  by the SysConfig tool.
 */
#ifndef ti_msp_dl_config_h
#define ti_msp_dl_config_h

#define CONFIG_MSPM0G350X
#define CONFIG_MSPM0G3507

#if defined(__ti_version__) || defined(__TI_COMPILER_VERSION__)
#define SYSCONFIG_WEAK __attribute__((weak))
#elif defined(__IAR_SYSTEMS_ICC__)
#define SYSCONFIG_WEAK __weak
#elif defined(__GNUC__)
#define SYSCONFIG_WEAK __attribute__((weak))
#endif

#include <ti/devices/msp/msp.h>
#include <ti/driverlib/driverlib.h>
#include <ti/driverlib/m0p/dl_core.h>

#ifdef __cplusplus
extern "C" {
#endif

/*
 *  ======== SYSCFG_DL_init ========
 *  Perform all required MSP DL initialization
 *
 *  This function should be called once at a point before any use of
 *  MSP DL.
 */


/* clang-format off */

#define POWER_STARTUP_DELAY                                                (16)



#define CPUCLK_FREQ                                                     32000000



/* Defines for PWM_0 */
#define PWM_0_INST                                                         TIMG0
#define PWM_0_INST_IRQHandler                                   TIMG0_IRQHandler
#define PWM_0_INST_INT_IRQN                                     (TIMG0_INT_IRQn)
#define PWM_0_INST_CLK_FREQ                                             32000000
/* GPIO defines for channel 0 */
#define GPIO_PWM_0_C0_PORT                                                 GPIOA
#define GPIO_PWM_0_C0_PIN                                         DL_GPIO_PIN_12
#define GPIO_PWM_0_C0_IOMUX                                      (IOMUX_PINCM34)
#define GPIO_PWM_0_C0_IOMUX_FUNC                     IOMUX_PINCM34_PF_TIMG0_CCP0
#define GPIO_PWM_0_C0_IDX                                    DL_TIMER_CC_0_INDEX
/* GPIO defines for channel 1 */
#define GPIO_PWM_0_C1_PORT                                                 GPIOA
#define GPIO_PWM_0_C1_PIN                                         DL_GPIO_PIN_13
#define GPIO_PWM_0_C1_IOMUX                                      (IOMUX_PINCM35)
#define GPIO_PWM_0_C1_IOMUX_FUNC                     IOMUX_PINCM35_PF_TIMG0_CCP1
#define GPIO_PWM_0_C1_IDX                                    DL_TIMER_CC_1_INDEX

/* Defines for PWM_1 */
#define PWM_1_INST                                                         TIMA0
#define PWM_1_INST_IRQHandler                                   TIMA0_IRQHandler
#define PWM_1_INST_INT_IRQN                                     (TIMA0_INT_IRQn)
#define PWM_1_INST_CLK_FREQ                                             32000000
/* GPIO defines for channel 0 */
#define GPIO_PWM_1_C0_PORT                                                 GPIOA
#define GPIO_PWM_1_C0_PIN                                         DL_GPIO_PIN_21
#define GPIO_PWM_1_C0_IOMUX                                      (IOMUX_PINCM46)
#define GPIO_PWM_1_C0_IOMUX_FUNC                     IOMUX_PINCM46_PF_TIMA0_CCP0
#define GPIO_PWM_1_C0_IDX                                    DL_TIMER_CC_0_INDEX
/* GPIO defines for channel 1 */
#define GPIO_PWM_1_C1_PORT                                                 GPIOA
#define GPIO_PWM_1_C1_PIN                                          DL_GPIO_PIN_3
#define GPIO_PWM_1_C1_IOMUX                                       (IOMUX_PINCM8)
#define GPIO_PWM_1_C1_IOMUX_FUNC                      IOMUX_PINCM8_PF_TIMA0_CCP1
#define GPIO_PWM_1_C1_IDX                                    DL_TIMER_CC_1_INDEX
/* GPIO defines for channel 3 */
#define GPIO_PWM_1_C3_PORT                                                 GPIOA
#define GPIO_PWM_1_C3_PIN                                          DL_GPIO_PIN_4
#define GPIO_PWM_1_C3_IOMUX                                       (IOMUX_PINCM9)
#define GPIO_PWM_1_C3_IOMUX_FUNC                      IOMUX_PINCM9_PF_TIMA0_CCP3
#define GPIO_PWM_1_C3_IDX                                    DL_TIMER_CC_3_INDEX



/* Defines for TIMER_0 */
#define TIMER_0_INST                                                     (TIMA1)
#define TIMER_0_INST_IRQHandler                                 TIMA1_IRQHandler
#define TIMER_0_INST_INT_IRQN                                   (TIMA1_INT_IRQn)
#define TIMER_0_INST_LOAD_VALUE                                          (9999U)



/* Defines for UART_0 */
#define UART_0_INST                                                        UART0
#define UART_0_INST_FREQUENCY                                           32000000
#define UART_0_INST_IRQHandler                                  UART0_IRQHandler
#define UART_0_INST_INT_IRQN                                      UART0_INT_IRQn
#define GPIO_UART_0_RX_PORT                                                GPIOA
#define GPIO_UART_0_TX_PORT                                                GPIOA
#define GPIO_UART_0_RX_PIN                                        DL_GPIO_PIN_11
#define GPIO_UART_0_TX_PIN                                        DL_GPIO_PIN_10
#define GPIO_UART_0_IOMUX_RX                                     (IOMUX_PINCM22)
#define GPIO_UART_0_IOMUX_TX                                     (IOMUX_PINCM21)
#define GPIO_UART_0_IOMUX_RX_FUNC                      IOMUX_PINCM22_PF_UART0_RX
#define GPIO_UART_0_IOMUX_TX_FUNC                      IOMUX_PINCM21_PF_UART0_TX
#define UART_0_BAUD_RATE                                                (115200)
#define UART_0_IBRD_32_MHZ_115200_BAUD                                      (17)
#define UART_0_FBRD_32_MHZ_115200_BAUD                                      (23)





/* Defines for ADC12_1 */
#define ADC12_1_INST                                                        ADC1
#define ADC12_1_INST_IRQHandler                                  ADC1_IRQHandler
#define ADC12_1_INST_INT_IRQN                                    (ADC1_INT_IRQn)
#define ADC12_1_ADCMEM_0                                      DL_ADC12_MEM_IDX_0
#define ADC12_1_ADCMEM_0_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_0_REF_VOLTAGE_V                                       3.3
#define ADC12_1_ADCMEM_1                                      DL_ADC12_MEM_IDX_1
#define ADC12_1_ADCMEM_1_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_1_REF_VOLTAGE_V                                       3.3
#define ADC12_1_ADCMEM_2                                      DL_ADC12_MEM_IDX_2
#define ADC12_1_ADCMEM_2_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_2_REF_VOLTAGE_V                                       3.3
#define ADC12_1_ADCMEM_3                                      DL_ADC12_MEM_IDX_3
#define ADC12_1_ADCMEM_3_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_3_REF_VOLTAGE_V                                       3.3
#define ADC12_1_ADCMEM_4                                      DL_ADC12_MEM_IDX_4
#define ADC12_1_ADCMEM_4_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_4_REF_VOLTAGE_V                                       3.3
#define ADC12_1_ADCMEM_5                                      DL_ADC12_MEM_IDX_5
#define ADC12_1_ADCMEM_5_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_5_REF_VOLTAGE_V                                       3.3
#define ADC12_1_ADCMEM_6                                      DL_ADC12_MEM_IDX_6
#define ADC12_1_ADCMEM_6_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_6_REF_VOLTAGE_V                                       3.3
#define ADC12_1_ADCMEM_7                                      DL_ADC12_MEM_IDX_7
#define ADC12_1_ADCMEM_7_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_7_REF_VOLTAGE_V                                       3.3
#define ADC12_1_ADCMEM_8                                      DL_ADC12_MEM_IDX_8
#define ADC12_1_ADCMEM_8_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_8_REF_VOLTAGE_V                                       3.3
#define ADC12_1_ADCMEM_9                                      DL_ADC12_MEM_IDX_9
#define ADC12_1_ADCMEM_9_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_9_REF_VOLTAGE_V                                       3.3
#define ADC12_1_ADCMEM_10                                    DL_ADC12_MEM_IDX_10
#define ADC12_1_ADCMEM_10_REF                    DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_10_REF_VOLTAGE_V                                      3.3
#define ADC12_1_ADCMEM_11                                    DL_ADC12_MEM_IDX_11
#define ADC12_1_ADCMEM_11_REF                    DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_1_ADCMEM_11_REF_VOLTAGE_V                                      3.3
#define GPIO_ADC12_1_C0_PORT                                               GPIOA
#define GPIO_ADC12_1_C0_PIN                                       DL_GPIO_PIN_15
#define GPIO_ADC12_1_C1_PORT                                               GPIOA
#define GPIO_ADC12_1_C1_PIN                                       DL_GPIO_PIN_16
#define GPIO_ADC12_1_C3_PORT                                               GPIOA
#define GPIO_ADC12_1_C3_PIN                                       DL_GPIO_PIN_18
#define GPIO_ADC12_1_C4_PORT                                               GPIOB
#define GPIO_ADC12_1_C4_PIN                                       DL_GPIO_PIN_17
#define GPIO_ADC12_1_C5_PORT                                               GPIOB
#define GPIO_ADC12_1_C5_PIN                                       DL_GPIO_PIN_18
#define GPIO_ADC12_1_C6_PORT                                               GPIOB
#define GPIO_ADC12_1_C6_PIN                                       DL_GPIO_PIN_19

/* Defines for ADC12_0 */
#define ADC12_0_INST                                                        ADC0
#define ADC12_0_INST_IRQHandler                                  ADC0_IRQHandler
#define ADC12_0_INST_INT_IRQN                                    (ADC0_INT_IRQn)
#define ADC12_0_ADCMEM_1                                      DL_ADC12_MEM_IDX_1
#define ADC12_0_ADCMEM_1_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_0_ADCMEM_1_REF_VOLTAGE_V                                       3.3
#define ADC12_0_ADCMEM_2                                      DL_ADC12_MEM_IDX_2
#define ADC12_0_ADCMEM_2_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_0_ADCMEM_2_REF_VOLTAGE_V                                       3.3
#define ADC12_0_ADCMEM_3                                      DL_ADC12_MEM_IDX_3
#define ADC12_0_ADCMEM_3_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_0_ADCMEM_3_REF_VOLTAGE_V                                       3.3
#define ADC12_0_ADCMEM_4                                      DL_ADC12_MEM_IDX_4
#define ADC12_0_ADCMEM_4_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_0_ADCMEM_4_REF_VOLTAGE_V                                       3.3
#define ADC12_0_ADCMEM_5                                      DL_ADC12_MEM_IDX_5
#define ADC12_0_ADCMEM_5_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_0_ADCMEM_5_REF_VOLTAGE_V                                       3.3
#define ADC12_0_ADCMEM_6                                      DL_ADC12_MEM_IDX_6
#define ADC12_0_ADCMEM_6_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_0_ADCMEM_6_REF_VOLTAGE_V                                       3.3
#define ADC12_0_ADCMEM_7                                      DL_ADC12_MEM_IDX_7
#define ADC12_0_ADCMEM_7_REF                     DL_ADC12_REFERENCE_VOLTAGE_VDDA
#define ADC12_0_ADCMEM_7_REF_VOLTAGE_V                                       3.3
#define GPIO_ADC12_0_C1_PORT                                               GPIOA
#define GPIO_ADC12_0_C1_PIN                                       DL_GPIO_PIN_26
#define GPIO_ADC12_0_C2_PORT                                               GPIOA
#define GPIO_ADC12_0_C2_PIN                                       DL_GPIO_PIN_25
#define GPIO_ADC12_0_C3_PORT                                               GPIOA
#define GPIO_ADC12_0_C3_PIN                                       DL_GPIO_PIN_24
#define GPIO_ADC12_0_C4_PORT                                               GPIOB
#define GPIO_ADC12_0_C4_PIN                                       DL_GPIO_PIN_25
#define GPIO_ADC12_0_C5_PORT                                               GPIOB
#define GPIO_ADC12_0_C5_PIN                                       DL_GPIO_PIN_24
#define GPIO_ADC12_0_C6_PORT                                               GPIOB
#define GPIO_ADC12_0_C6_PIN                                       DL_GPIO_PIN_20
#define GPIO_ADC12_0_C7_PORT                                               GPIOA
#define GPIO_ADC12_0_C7_PIN                                       DL_GPIO_PIN_22



/* Port definition for Pin Group USER_GPIO */
#define USER_GPIO_PORT                                                   (GPIOA)

/* Defines for LED_PA0: GPIOA.0 with pinCMx 1 on package pin 33 */
#define USER_GPIO_LED_PA0_PIN                                    (DL_GPIO_PIN_0)
#define USER_GPIO_LED_PA0_IOMUX                                   (IOMUX_PINCM1)
/* Port definition for Pin Group PORTA */
#define PORTA_PORT                                                       (GPIOA)

/* Defines for OLED_SCL: GPIOA.17 with pinCMx 39 on package pin 10 */
#define PORTA_OLED_SCL_PIN                                      (DL_GPIO_PIN_17)
#define PORTA_OLED_SCL_IOMUX                                     (IOMUX_PINCM39)
/* Port definition for Pin Group PORTB */
#define PORTB_PORT                                                       (GPIOB)

/* Defines for OLED_SDA: GPIOB.15 with pinCMx 32 on package pin 3 */
#define PORTB_OLED_SDA_PIN                                      (DL_GPIO_PIN_15)
#define PORTB_OLED_SDA_IOMUX                                     (IOMUX_PINCM32)
/* Port definition for Pin Group BUTTON */
#define BUTTON_PORT                                                      (GPIOB)

/* Defines for PIN_K1: GPIOB.21 with pinCMx 49 on package pin 20 */
#define BUTTON_PIN_K1_PIN                                       (DL_GPIO_PIN_21)
#define BUTTON_PIN_K1_IOMUX                                      (IOMUX_PINCM49)
/* Port definition for Pin Group AIN */
#define AIN_PORT                                                         (GPIOA)

/* Defines for AIN1: GPIOA.6 with pinCMx 11 on package pin 46 */
#define AIN_AIN1_PIN                                             (DL_GPIO_PIN_6)
#define AIN_AIN1_IOMUX                                           (IOMUX_PINCM11)
/* Defines for AIN2: GPIOA.5 with pinCMx 10 on package pin 45 */
#define AIN_AIN2_PIN                                             (DL_GPIO_PIN_5)
#define AIN_AIN2_IOMUX                                           (IOMUX_PINCM10)
/* Port definition for Pin Group BIN */
#define BIN_PORT                                                         (GPIOA)

/* Defines for BIN1: GPIOA.30 with pinCMx 5 on package pin 37 */
#define BIN_BIN1_PIN                                            (DL_GPIO_PIN_30)
#define BIN_BIN1_IOMUX                                            (IOMUX_PINCM5)
/* Defines for BIN2: GPIOA.31 with pinCMx 6 on package pin 39 */
#define BIN_BIN2_PIN                                            (DL_GPIO_PIN_31)
#define BIN_BIN2_IOMUX                                            (IOMUX_PINCM6)
/* Port definition for Pin Group CIN */
#define CIN_PORT                                                         (GPIOA)

/* Defines for CIN1: GPIOA.1 with pinCMx 2 on package pin 34 */
#define CIN_CIN1_PIN                                             (DL_GPIO_PIN_1)
#define CIN_CIN1_IOMUX                                            (IOMUX_PINCM2)
/* Defines for CIN2: GPIOA.14 with pinCMx 36 on package pin 7 */
#define CIN_CIN2_PIN                                            (DL_GPIO_PIN_14)
#define CIN_CIN2_IOMUX                                           (IOMUX_PINCM36)
/* Port definition for Pin Group DIN */
#define DIN_PORT                                                         (GPIOB)

/* Defines for DIN1: GPIOB.2 with pinCMx 15 on package pin 50 */
#define DIN_DIN1_PIN                                             (DL_GPIO_PIN_2)
#define DIN_DIN1_IOMUX                                           (IOMUX_PINCM15)
/* Defines for DIN2: GPIOB.26 with pinCMx 57 on package pin 28 */
#define DIN_DIN2_PIN                                            (DL_GPIO_PIN_26)
#define DIN_DIN2_IOMUX                                           (IOMUX_PINCM57)
/* Port definition for Pin Group E1_ENCODER */
#define E1_ENCODER_PORT                                                  (GPIOB)

/* Defines for E1A: GPIOB.0 with pinCMx 12 on package pin 47 */
// groups represented: ["E2_ENCODER","E3_ENCODER","E4_ENCODER","E1_ENCODER"]
// pins affected: ["E2A0","E3A","E4A","E1A"]
#define GPIO_MULTIPLE_GPIOB_INT_IRQN                            (GPIOB_INT_IRQn)
#define GPIO_MULTIPLE_GPIOB_INT_IIDX            (DL_INTERRUPT_GROUP1_IIDX_GPIOB)
#define E1_ENCODER_E1A_IIDX                                  (DL_GPIO_IIDX_DIO0)
#define E1_ENCODER_E1A_PIN                                       (DL_GPIO_PIN_0)
#define E1_ENCODER_E1A_IOMUX                                     (IOMUX_PINCM12)
/* Defines for E1B: GPIOB.1 with pinCMx 13 on package pin 48 */
#define E1_ENCODER_E1B_PIN                                       (DL_GPIO_PIN_1)
#define E1_ENCODER_E1B_IOMUX                                     (IOMUX_PINCM13)
/* Port definition for Pin Group E2_ENCODER */
#define E2_ENCODER_PORT                                                  (GPIOB)

/* Defines for E2A0: GPIOB.3 with pinCMx 16 on package pin 51 */
#define E2_ENCODER_E2A0_IIDX                                 (DL_GPIO_IIDX_DIO3)
#define E2_ENCODER_E2A0_PIN                                      (DL_GPIO_PIN_3)
#define E2_ENCODER_E2A0_IOMUX                                    (IOMUX_PINCM16)
/* Defines for E2B0: GPIOB.4 with pinCMx 17 on package pin 52 */
#define E2_ENCODER_E2B0_PIN                                      (DL_GPIO_PIN_4)
#define E2_ENCODER_E2B0_IOMUX                                    (IOMUX_PINCM17)
/* Port definition for Pin Group E3_ENCODER */
#define E3_ENCODER_PORT                                                  (GPIOB)

/* Defines for E3A: GPIOB.13 with pinCMx 30 on package pin 1 */
#define E3_ENCODER_E3A_IIDX                                 (DL_GPIO_IIDX_DIO13)
#define E3_ENCODER_E3A_PIN                                      (DL_GPIO_PIN_13)
#define E3_ENCODER_E3A_IOMUX                                     (IOMUX_PINCM30)
/* Defines for E3B: GPIOB.14 with pinCMx 31 on package pin 2 */
#define E3_ENCODER_E3B_PIN                                      (DL_GPIO_PIN_14)
#define E3_ENCODER_E3B_IOMUX                                     (IOMUX_PINCM31)
/* Port definition for Pin Group E4_ENCODER */
#define E4_ENCODER_PORT                                                  (GPIOB)

/* Defines for E4A: GPIOB.22 with pinCMx 50 on package pin 21 */
#define E4_ENCODER_E4A_IIDX                                 (DL_GPIO_IIDX_DIO22)
#define E4_ENCODER_E4A_PIN                                      (DL_GPIO_PIN_22)
#define E4_ENCODER_E4A_IOMUX                                     (IOMUX_PINCM50)
/* Defines for E4B: GPIOB.23 with pinCMx 51 on package pin 22 */
#define E4_ENCODER_E4B_PIN                                      (DL_GPIO_PIN_23)
#define E4_ENCODER_E4B_IOMUX                                     (IOMUX_PINCM51)

/* clang-format on */

void SYSCFG_DL_init(void);
void SYSCFG_DL_initPower(void);
void SYSCFG_DL_GPIO_init(void);
void SYSCFG_DL_SYSCTL_init(void);
void SYSCFG_DL_PWM_0_init(void);
void SYSCFG_DL_PWM_1_init(void);
void SYSCFG_DL_TIMER_0_init(void);
void SYSCFG_DL_UART_0_init(void);
void SYSCFG_DL_ADC12_1_init(void);
void SYSCFG_DL_ADC12_0_init(void);


bool SYSCFG_DL_saveConfiguration(void);
bool SYSCFG_DL_restoreConfiguration(void);

#ifdef __cplusplus
}
#endif

#endif /* ti_msp_dl_config_h */
